<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // eval 可以将一段字符串当作js代码来执行
    var str = '1+1'

    var num = eval(str)

    console.log(num)

  </script>
</body>
</html>